(define (fast-expt b n)
  (fast-expt-iter b n 1))

(define (fast-expt-iter b n a)
  (cond ((= n 0) a)
        ((even? n) (fast-expt-iter (square b) (/ n 2) a))
        (else (fast-expt-iter b (- n 1) (* a b)))))

(define (square x)
  (* x x))

fei(2 10 1)
fei(4 5 1)
fei(4 4 4)
fei(16 2 4)
fei(256 1 4)
fei(256 0 1024)
